<!-- 分类授权编辑页面 -->
<extend name="common/base" />
<block name="body">
    <form data-toggle="ajaxform" action="{:url('Auth/addToCategory')}" method="post" enctype="application/x-www-form-urlencoded">
        <input type="hidden" name="group_id" value="{$group_id}">
        <input type="hidden" name="cids" id="cids" value="">
        <ul id="auth_category" class="ztree" data-toggle="ztree"
            data-options="{
                expandAll: true,
                checkEnable: true,
            }"
        >
            <volist name="group_list" id="cat">
            <li data-id="{$cat.catid}" data-pid="{$cat.upid}" data-checked="{:in_array($cat['catid'], $authed_group)}" data-faicon="rss" data-faicon-close="cab">{$cat.catname}</li>
            </volist>
        </ul>

        <div class="tb-unit-bar">
            <button class="btn btn-success ajax-post" onclick="getchecked()">确 定</button>
            <button class="btn btn-danger" onclick="$.zui.dialog('closeCurrent');return false;">返 回</button>
        </div>
    </form>
</block>
<block name="script">
<script type="text/javascript">
function getchecked(){
    var zobj = $.fn.zTree.getZTreeObj('auth_category');
    var checked = zobj.getCheckedNodes();
    if(checked.length>0) {
        var cids = new Array();
        $.each(checked, function(index, node) {
            cids.push(node.getId());
        });
        $('#cids').val(cids.join(','));
    } else {
        $('#cids').val();
    }
}
</script>
</block>
